/**
 * @Author: 魏巍 <jswei>
 * @Date:   2018-08-17T07:39:12+08:00
 * @Email:  524314430@qq.com
 * @Filename: reset.js
 * @Last modified by:   jswei
 * @Last modified time: 2018-08-28T04:31:33+08:00
 * @Copyright: free
 */

(function (doc, win) {
  var docEl = doc.documentElement,
    resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
    recalc = function () {
      var clientWidth = docEl.clientWidth;
      if (!clientWidth) return;
      docEl.style.fontSize = 20 * (clientWidth / 320) + 'px';
    };

  if (!doc.addEventListener) return;
  win.addEventListener(resizeEvt, recalc, false);
  doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);
